package request;

import java.sql.Timestamp;
import java.util.Date;

import record.ProjectRecord;
import record.Record;

/**
 * SaveRequest is a class that is used to send a request to the server to save a record.
 * @author Sean Freitag
 * @author Jacob Freemyer
 * @author Stephan Jossie
 *
 */
@SuppressWarnings("serial")
public class SaveRequest implements Request {
	/**
	 * Record to save
	 */
	private Record record;
	
	/**
	 * Creates an instance of SaveRequest to tell the server to save the record to the database.
	 */
	public SaveRequest() {
		record = null;
	}

	/**
	 * Getter that gets the record to be saved to the database
	 * @return
	 * 		Record being saved
	 */
	public Record getRecord()
	{
		return record;
	}
	
	/**
	 * Setter for setting the record to save
	 * @param pRecord
	 * Record to save
	 */
	public void setRecord(Record pRecord)
	{
		record = pRecord;
		if(record.getClass().equals(ProjectRecord.class))
		{
			((ProjectRecord) record).getMetaData().setLastSaved(new Timestamp(new Date().getTime()));
		}
	}
	{
		
	}
}
